<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Language" content="zh-cn" />
    <title>排序</title>
    <script>
    </script>
    <style>
        .content {
            background-color: pink;
            text-align: center;
            margin-top: 100px;
            height: 300px;
            width: 800px;
            margin-left: 25%;

        }

        .content_ifr {
            text-align: center;
            background-color: aquamarine;
            height: 250px;
            width: 800px;

            margin-left: 25%;
        }

        #ifr {
            background-color: purple;
            text-align: center;
        }
    </style>
</head>

<body>
    <div class="content">
        <form>
            <input id="input" type="text" placeholder="请输入一个数字" value="3" /><br>
            <input type="text" placeholder="请输入一个数字" value="3" /><br>
            <input type="text" placeholder="请输入一个数字" value="6" /><br>
            <input type="text" placeholder="请输入一个数字" value="1" /><br>
            <input type="text" placeholder="请输入一个数字" value="14" /><br>
            <input type="text" placeholder="请输入一个数字" value="7" />
        </form>
        <button onclick="sort()">排序</button>
    </div>
    <!--   <div class="output"></div> -->

    <div class="content_ifr"><iframe src="" frameborder="0" id="ifr"></iframe></div>
    <script>
        function sort() {
            var result = new Array();
            var num_char = new Array();

            for (i = 0; i < 6; i++) {
                num_char[i] = document.getElementsByTagName('input')[i].value;//注意此时的值为字符类型
                result[i] = Number(num_char[i]);//将字符转化成数字
            }
            for (var it = 0; it < result.length; it++) {
                for (var i = it + 1; i < result.length; i++) {
                    if (result[it] > result[i]) {
                        var temp;
                        temp = result[it];
                        result[it] = result[i];
                        result[i] = temp;
                    }
                }
            }

            var ifr = document.getElementById("ifr");
            var ifrdoc = ifr.contentWindow.document;
            for (i = 0; i < 6; i++) {
                ifrdoc.write("--" + result[i] + "--");

            }

        }
    </script>
</body>

</html>